<template>
  <div class="prompt-container">
    <div class="prompt-box">
      <div class="prompt-title">
        <div style="display: flex; align-items: center">
          <svg-icon
            icon-class="peizhi_icon"
            style="width: 16px; height: 16px; margin-right: 8px"
          />
          <div>服务器连接配置</div>
        </div>
        <el-icon color="#fff" @click="cancellation" size="16"><Close /></el-icon>
      </div>
      <div style="max-height:670px;overflow-y: auto;">
        <div class="prompt-content">
        <div class="mabiao">
          <div class="mabiao-item">
            <div class="mabiao-item-left">服务器IP</div>
            <div>
                <el-input v-model="ruleForm.region" style="width: 260px;margin-left:8px;" placeholder="请输入服务器ip" />
            </div>
          </div>
          <div class="mabiao-item">
            <div class="mabiao-item-left">服务器端口</div>
            <div>
                <el-input v-model="ruleForm.region" style="width: 260px;margin-left:8px;" placeholder="请输入服务器端口" />
            </div>
          </div>
        </div>
        <div class="mabiao">
          <div class="mabiao-item">
            <div class="mabiao-item-left">服务代理地址</div>
            <div>
                <el-input v-model="ruleForm.region" style="width: 260px;margin-left:8px;" placeholder="请输入服务代理地址" />
            </div>
          </div>
          <div class="mabiao-item">
            <div class="mabiao-item-left">医保服务IP</div>
            <div>
                <el-input v-model="ruleForm.region" style="width: 260px;margin-left:8px;" placeholder="请输入医保服务IP" />
            </div>
          </div>
        </div>
        <div class="mabiao">
          <div class="mabiao-item">
            <div class="mabiao-item-left">医保服务端口</div>
            <div>
                <el-input v-model="ruleForm.region" style="width: 260px;margin-left:8px;" placeholder="请输入医保服务端口" />
            </div>
          </div>
          <div class="mabiao-item">
            <div class="mabiao-item-left">自动更新IP</div>
            <div>
                <el-input v-model="ruleForm.region" style="width: 260px;margin-left:8px;" placeholder="请输入自动更新IP" />
            </div>
          </div>
        </div>
        <div class="mabiao" style="margin-bottom:0">
          <div class="mabiao-item">
            <div class="mabiao-item-left">自动更新端口</div>
            <div>
                <el-input v-model="ruleForm.region" style="width: 260px;margin-left:8px;" placeholder="请输入自动更新端口" />
            </div>
          </div>
          <div class="mabiao-item">
            <div class="mabiao-item-left">文字大小</div>
            <div>
                <el-input v-model="ruleForm.region" style="width: 260px;margin-left:8px;" placeholder="请输入IP地址" />
            </div>
          </div>
        </div>
        <div class="prompt-line"></div>

        <div class="prompt-wcf">
          <div class="prompt-wcf-top">
            <div style="display:flex;align-items: center;">
              <div class="prompt-wcf-top-title">wcf连接地址</div>
              <div class="prompt-wcf-top-box">
                <div class="prompt-wcf-top-box-ip">IP地址</div>
                <div class="prompt-wcf-top-box-di">
                  <el-input v-model="wcfruleForm.regionip" style="width: 170px;" placeholder="请输入IP地址" />
                </div>
              </div>
              <div class="prompt-wcf-top-box">
                <div class="prompt-wcf-top-box-ip">端口</div>
                <div class="prompt-wcf-top-box-di">
                  <el-input v-model="wcfruleForm.regiondk" style="width: 170px;" placeholder="请输入端口" />
                </div>
              </div>
            </div>
            <div class="prompt-wcf-top-right" @click="wcfxiang">
              <div v-if="wcfinfo">
                收起详情
              </div>
              <div v-else>
                展开详情
              </div>
              <svg-icon
                v-if="wcfinfo"
                icon-class="shuangxia"
                style="width: 16px; height: 16px; margin-right: 4px"
              />
              <svg-icon
                v-else
                icon-class="shuangshang"
                style="width: 16px; height: 16px; margin-right: 4px"
              />
            </div>
          </div>
          <div style="width: 100%;">
            <el-collapse-transition>
              <div v-show="wcfinfo">
                <div style="height:16px"></div>
                <div class="prompt-wcf-center">
                  <div class="prompt-wcf-center-item">
                    <div class="prompt-wcf-center-item-soft">
                      <div class="prompt-wcf-center-item-label">公共接口</div>
                      <div style="display: flex;align-items: center;flex:1">
                        <el-input v-model="wcfruleForm.HosptalServerip" style="width: 140px;margin:0 8px 0 8px" placeholder="请输入IP地址" />
                        <el-input v-model="wcfruleForm.HosptalServerdk" style="width: 140px" placeholder="请输入端口号" />
                      </div>
                    </div>
                    <div class="prompt-wcf-center-item-soft">
                      <div class="prompt-wcf-center-item-label">门诊接口</div>
                      <div style="display: flex;align-items: center;flex:1">
                        <el-input v-model="wcfruleForm.MzHosptalServerip" style="width: 140px;margin:0 8px 0 8px" placeholder="请输入IP地址" />
                        <el-input v-model="wcfruleForm.MzHosptalServerdk" style="width: 140px" placeholder="请输入端口号" />
                      </div>
                    </div>
                  </div>
                  <div class="prompt-wcf-center-item">
                    <div class="prompt-wcf-center-item-soft">
                      <div class="prompt-wcf-center-item-label">医保接口</div>
                      <div style="display: flex;align-items: center;flex:1">
                        <el-input v-model="wcfruleForm.YbHosptalServerip" style="width: 140px;margin:0 8px 0 8px" placeholder="请输入IP地址" />
                        <el-input v-model="wcfruleForm.YbHosptalServerdk" style="width: 140px" placeholder="请输入端口号" />
                      </div>
                    </div>
                    <div class="prompt-wcf-center-item-soft">
                      <div class="prompt-wcf-center-item-label">药库接口</div>
                      <div style="display: flex;align-items: center;flex:1">
                        <el-input v-model="wcfruleForm.YkHosptalServerip" style="width: 140px;margin:0 8px 0 8px" placeholder="请输入IP地址" />
                        <el-input v-model="wcfruleForm.YkHosptalServerdk" style="width: 140px" placeholder="请输入端口号" />
                      </div>
                    </div>
                  </div>
                  <div class="prompt-wcf-center-item">
                    <div class="prompt-wcf-center-item-soft">
                      <div class="prompt-wcf-center-item-label">电子病历接口</div>
                      <div style="display: flex;align-items: center;flex:1">
                        <el-input v-model="wcfruleForm.DzblHosptalServerip" style="width: 140px;margin:0 8px 0 8px" placeholder="请输入IP地址" />
                        <el-input v-model="wcfruleForm.DzblHosptalServerdk" style="width: 140px" placeholder="请输入端口号" />
                      </div>
                    </div>
                    <div class="prompt-wcf-center-item-soft">
                      <div class="prompt-wcf-center-item-label">报表接口</div>
                      <div style="display: flex;align-items: center;flex:1">
                        <el-input v-model="wcfruleForm.BbHosptalServerip" style="width: 140px;margin:0 8px 0 8px" placeholder="请输入IP地址" />
                        <el-input v-model="wcfruleForm.BbHosptalServerdk" style="width: 140px" placeholder="请输入端口号" />
                      </div>
                    </div>
                  </div>
                  <div class="prompt-wcf-center-item">
                    <div class="prompt-wcf-center-item-soft">
                      <div class="prompt-wcf-center-item-label">住院接口</div>
                      <div style="display: flex;align-items: center;flex:1">
                        <el-input v-model="wcfruleForm.ZyHosptalServerip" style="width: 140px;margin:0 8px 0 8px" placeholder="请输入IP地址" />
                        <el-input v-model="wcfruleForm.ZyHosptalServerdk" style="width: 140px" placeholder="请输入端口号" />
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </el-collapse-transition>
          </div>
        </div>

        <div class="prompt-wcf" style="margin-top:20px">
          <div class="prompt-wcf-top">
            <div style="display:flex;align-items: center;">
              <div class="prompt-wcf-top-title">http连接地址</div>
              <div class="prompt-wcf-top-box">
                <div class="prompt-wcf-top-box-ip">IP地址</div>
                <div class="prompt-wcf-top-box-di">
                  <el-input v-model="httpruleForm.regionip" style="width: 170px;" placeholder="请输入IP地址" />
                </div>
              </div>
              <div class="prompt-wcf-top-box">
                <div class="prompt-wcf-top-box-ip">端口</div>
                <div class="prompt-wcf-top-box-di">
                  <el-input v-model="httpruleForm.regiondk" style="width: 170px;" placeholder="请输入端口" />
                </div>
              </div>
            </div>
            <div class="prompt-wcf-top-right" @click="httpxiang">
              <div v-if="httpinfo">
                收起详情
              </div>
              <div v-else>
                展开详情
              </div>
              <svg-icon
                v-if="httpinfo"
                icon-class="shuangxia"
                style="width: 16px; height: 16px; margin-right: 4px"
              />
              <svg-icon
                v-else
                icon-class="shuangshang"
                style="width: 16px; height: 16px; margin-right: 4px"
              />
            </div>
          </div>
          <div style="width: 100%;margin-top: 16px;">
            <el-collapse-transition>
              <div v-show="httpinfo">
                <div class="prompt-wcf-center">
                  <div class="prompt-wcf-center-item">
                    <div class="prompt-wcf-center-item-soft">
                      <div class="prompt-wcf-center-item-label">公共接口</div>
                      <div style="display: flex;align-items: center;flex:1">
                        <el-input v-model="httpruleForm.httphosptalserverip" style="width: 140px;margin:0 8px 0 8px" placeholder="请输入IP地址" />
                        <el-input v-model="httpruleForm.httphosptalserverdk" style="width: 140px" placeholder="请输入端口号" />
                      </div>
                    </div>
                    <div class="prompt-wcf-center-item-soft">
                      <div class="prompt-wcf-center-item-label">门诊接口</div>
                      <div style="display: flex;align-items: center;flex:1">
                        <el-input v-model="httpruleForm.mzhttphosptalserverip" style="width: 140px;margin:0 8px 0 8px" placeholder="请输入IP地址" />
                        <el-input v-model="httpruleForm.mzhttphosptalserverdk" style="width: 140px" placeholder="请输入端口号" />
                      </div>
                    </div>
                  </div>
                  <div class="prompt-wcf-center-item">
                    <div class="prompt-wcf-center-item-soft">
                      <div class="prompt-wcf-center-item-label">医保接口</div>
                      <div style="display: flex;align-items: center;flex:1">
                        <el-input v-model="httpruleForm.ybhttphosptalserverip" style="width: 140px;margin:0 8px 0 8px" placeholder="请输入IP地址" />
                        <el-input v-model="httpruleForm.ybhttphosptalserverdk" style="width: 140px" placeholder="请输入端口号" />
                      </div>
                    </div>
                    <div class="prompt-wcf-center-item-soft">
                      <div class="prompt-wcf-center-item-label">药库接口</div>
                      <div style="display: flex;align-items: center;flex:1">
                        <el-input v-model="httpruleForm.ykhttphosptalserverip" style="width: 140px;margin:0 8px 0 8px" placeholder="请输入IP地址" />
                        <el-input v-model="httpruleForm.ykhttphosptalserverdk" style="width: 140px" placeholder="请输入端口号" />
                      </div>
                    </div>
                  </div>
                  <div class="prompt-wcf-center-item">
                    <div class="prompt-wcf-center-item-soft">
                      <div class="prompt-wcf-center-item-label">电子病历接口</div>
                      <div style="display: flex;align-items: center;flex:1">
                        <el-input v-model="httpruleForm.dzblhttphosptalserverip" style="width: 140px;margin:0 8px 0 8px" placeholder="请输入IP地址" />
                        <el-input v-model="httpruleForm.dzblhttphosptalserverdk" style="width: 140px" placeholder="请输入端口号" />
                      </div>
                    </div>
                    <div class="prompt-wcf-center-item-soft">
                      <div class="prompt-wcf-center-item-label">报表接口</div>
                      <div style="display: flex;align-items: center;flex:1">
                        <el-input v-model="httpruleForm.bbhttphosptalserverip" style="width: 140px;margin:0 8px 0 8px" placeholder="请输入IP地址" />
                        <el-input v-model="httpruleForm.bbhttphosptalserverdk" style="width: 140px" placeholder="请输入端口号" />
                      </div>
                    </div>
                  </div>
                  <div class="prompt-wcf-center-item">
                    <div class="prompt-wcf-center-item-soft">
                      <div class="prompt-wcf-center-item-label">住院接口</div>
                      <div style="display: flex;align-items: center;flex:1">
                        <el-input v-model="httpruleForm.zyhttphosptalserverip" style="width: 140px;margin:0 8px 0 8px" placeholder="请输入IP地址" />
                        <el-input v-model="httpruleForm.zyhttphosptalserverdk" style="width: 140px" placeholder="请输入端口号" />
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </el-collapse-transition>
          </div>
        </div>
        
      </div>

      </div>
      
      <div class="prompt-footer">
        <el-button style="width:72px" @click="cancellation">取消</el-button>
        <el-button style="width:72px" type="primary" @click="cancelPrompt">确定</el-button>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref, onMounted } from "vue";
const { proxy } = getCurrentInstance();
const emit = defineEmits(['cancelPrompt','cancellation'])
const wcfinfo = ref(false)
const httpinfo = ref(false)
const ruleForm = ref({
  region: "",
  zhanghao: "",
  psd: "",
});
const wcfruleForm = ref({
  regionip:'',
  regiondk:'',
  HosptalServerip:'',
  HosptalServerdk:'',
  MzHosptalServerip:'',
  MzHosptalServerdk:'',
  YbHosptalServerip:'',
  YbHosptalServerdk:'',
  YkHosptalServerip:'',
  YkHosptalServerdk:'',
  DzblHosptalServerip:'',
  DzblHosptalServerdk:'',
  BbHosptalServerip:'',
  BbHosptalServerdk:'',
  ZyHosptalServerip:'',
  ZyHosptalServerdk:''
})
const httpruleForm = ref({
  regionip:'',
  regiondk:'',
  httphosptalserverip:'',
  httphosptalserverdk:'',
  mzhttphosptalserverip:'',
  mzhttphosptalserverdk:'',
  ybhttphosptalserverip:'',
  ybhttphosptalserverdk:'',
  ykhttphosptalserverip:'',
  ykhttphosptalserverdk:'',
  dzblhttphosptalserverip:'',
  dzblhttphosptalserverdk:'',
  bbhttphosptalserverip:'',
  bbhttphosptalserverdk:'',
  zyhttphosptalserverip:'',
  zyhttphosptalserverdk:''
})
const wcfruleForms = ref(null)
const httpruleForms = ref(null)
const input = ref('')

const wcfxiang = () => {
  wcfinfo.value = !wcfinfo.value
}

const httpxiang = () => {
  httpinfo.value = !httpinfo.value
}

const cancelPrompt = async() => {
  if(wcfruleForm.value.regionip && wcfruleForm.value.regiondk){
    replaceIpsInObject(wcfruleForms.value,wcfruleForm.value.regionip)
    replacePorts(wcfruleForms.value,wcfruleForm.value.regiondk)
    console.log(wcfruleForms.value);
  }else if(wcfruleForm.value.regionip){
    replaceIpsInObject(wcfruleForms.value,wcfruleForm.value.regionip)
    console.log(wcfruleForms.value);

  }else if(wcfruleForm.value.regiondk){
    replacePorts(wcfruleForms.value,wcfruleForm.value.regiondk)
    console.log(wcfruleForms.value);
  }else{
    wcfruleForms.value.HosptalServer = replaceIPsInString(wcfruleForms.value.HosptalServer,wcfruleForm.value.HosptalServerip)
    wcfruleForms.value.HosptalServer = replacePort(wcfruleForms.value.HosptalServer,wcfruleForm.value.HosptalServerdk)
    wcfruleForms.value.MzHosptalServer = replaceIPsInString(wcfruleForms.value.MzHosptalServer,wcfruleForm.value.MzHosptalServerip)
    wcfruleForms.value.MzHosptalServer = replacePort(wcfruleForms.value.MzHosptalServer,wcfruleForm.value.MzHosptalServerdk)
    wcfruleForms.value.YbHosptalServer = replaceIPsInString(wcfruleForms.value.YbHosptalServer,wcfruleForm.value.YbHosptalServerip)
    wcfruleForms.value.YbHosptalServer = replacePort(wcfruleForms.value.YbHosptalServer,wcfruleForm.value.YbHosptalServerdk)
    wcfruleForms.value.YkHosptalServer = replaceIPsInString(wcfruleForms.value.YkHosptalServer,wcfruleForm.value.YkHosptalServerip)
    wcfruleForms.value.YkHosptalServer = replacePort(wcfruleForms.value.YkHosptalServer,wcfruleForm.value.YkHosptalServerdk)
    wcfruleForms.value.DzblHosptalServer = replaceIPsInString(wcfruleForms.value.DzblHosptalServer,wcfruleForm.value.DzblHosptalServerip)
    wcfruleForms.value.DzblHosptalServer = replacePort(wcfruleForms.value.DzblHosptalServer,wcfruleForm.value.DzblHosptalServerdk)
    wcfruleForms.value.BbHosptalServer = replaceIPsInString(wcfruleForms.value.BbHosptalServer,wcfruleForm.value.BbHosptalServerip)
    wcfruleForms.value.BbHosptalServer = replacePort(wcfruleForms.value.BbHosptalServer,wcfruleForm.value.BbHosptalServerdk)
    wcfruleForms.value.ZyHosptalServer = replaceIPsInString(wcfruleForms.value.ZyHosptalServer,wcfruleForm.value.ZyHosptalServerip)
    wcfruleForms.value.ZyHosptalServer = replacePort(wcfruleForms.value.ZyHosptalServer,wcfruleForm.value.ZyHosptalServerdk)
  }
  if(httpruleForm.value.regionip && httpruleForm.value.regiondk){
    replaceIpsInObject(httpruleForms.value,httpruleForm.value.regionip)
    replacePorts(httpruleForms.value,httpruleForm.value.regiondk)
  }else if(httpruleForm.value.regionip){
    replaceIpsInObject(httpruleForms.value,httpruleForm.value.regionip)
  }else if(httpruleForm.value.regiondk){
    replacePorts(httpruleForms.value,httpruleForm.value.regiondk)
  }else{
    httpruleForms.value.httphosptalserver = replaceIPsInString(httpruleForms.value.httphosptalserver,httpruleForm.value.httphosptalserverip)
    httpruleForms.value.httphosptalserver = replacePort(httpruleForms.value.httphosptalserver,httpruleForm.value.httphosptalserverdk)
    httpruleForms.value.mzhttphosptalserver = replaceIPsInString(httpruleForms.value.mzhttphosptalserver,httpruleForm.value.mzhttphosptalserverip)
    httpruleForms.value.mzhttphosptalserver = replacePort(httpruleForms.value.mzhttphosptalserver,httpruleForm.value.mzhttphosptalserverdk)
    httpruleForms.value.ybhttphosptalserver = replaceIPsInString(httpruleForms.value.ybhttphosptalserver,httpruleForm.value.ybhttphosptalserverip)
    httpruleForms.value.ybhttphosptalserver = replacePort(httpruleForms.value.ybhttphosptalserver,httpruleForm.value.ybhttphosptalserverdk)
    httpruleForms.value.ykhttphosptalserver = replaceIPsInString(httpruleForms.value.ykhttphosptalserver,httpruleForm.value.ykhttphosptalserverip)
    httpruleForms.value.ykhttphosptalserver = replacePort(httpruleForms.value.ykhttphosptalserver,httpruleForm.value.ykhttphosptalserverdk)
    httpruleForms.value.dzblhttphosptalserver = replaceIPsInString(httpruleForms.value.dzblhttphosptalserver,httpruleForm.value.dzblhttphosptalserverip)
    httpruleForms.value.dzblhttphosptalserver = replacePort(httpruleForms.value.dzblhttphosptalserver,httpruleForm.value.dzblhttphosptalserverdk)
    httpruleForms.value.bbhttphosptalserver = replaceIPsInString(httpruleForms.value.bbhttphosptalserver,httpruleForm.value.bbhttphosptalserverip)
    httpruleForms.value.bbhttphosptalserver = replacePort(httpruleForms.value.bbhttphosptalserver,httpruleForm.value.bbhttphosptalserverdk)
    httpruleForms.value.zyhttphosptalserver = replaceIPsInString(httpruleForms.value.zyhttphosptalserver,httpruleForm.value.zyhttphosptalserverip)
    httpruleForms.value.zyhttphosptalserver = replacePort(httpruleForms.value.zyhttphosptalserver,httpruleForm.value.zyhttphosptalserverdk)
  }
  console.log(wcfruleForms.value,httpruleForms.value);
  let res = await window.xinpuWebsApi('SetGhyyInfo',{root:'WcfConnections',json:wcfruleForms.value})
  if(res.Flag){
    let result = await window.xinpuWebsApi('SetGhyyInfo',{root:'HttpConnections',json:httpruleForms.value})
    if(result.Flag){
      window.xinpuMessageOpen('success','配置成功')
      emit('cancelPrompt')
    }else{
      window.xinpuMessageOpen('error',result.codeMsg)
    }
  }else{
    window.xinpuMessageOpen('error',res.codeMsg)
  }
};

const cancellation = () => {
  emit('cancellation')
}

const getGhyyy = async() => {
  let res = await window.xinpuWebsApi('GetGhyyInfo',{root:'WcfConnections'})
  console.log(res);
  if(res.Flag){
    let result = JSON.parse(res.ReContent)
    console.log(result,'配置信息');
    wcfruleForms.value = result
    wcfruleForm.value.HosptalServerip = parseIp(result.HosptalServer)
    wcfruleForm.value.HosptalServerdk = parsePort(result.HosptalServer)
    wcfruleForm.value.MzHosptalServerip = parseIp(result.MzHosptalServer)
    wcfruleForm.value.MzHosptalServerdk = parsePort(result.MzHosptalServer)
    wcfruleForm.value.YbHosptalServerip = parseIp(result.YbHosptalServer)
    wcfruleForm.value.YbHosptalServerdk = parsePort(result.YbHosptalServer)
    wcfruleForm.value.YkHosptalServerip = parseIp(result.YkHosptalServer)
    wcfruleForm.value.YkHosptalServerdk = parsePort(result.YkHosptalServer)
    wcfruleForm.value.DzblHosptalServerip = parseIp(result.DzblHosptalServer)
    wcfruleForm.value.DzblHosptalServerdk = parsePort(result.DzblHosptalServer)
    wcfruleForm.value.BbHosptalServerip = parseIp(result.BbHosptalServer)
    wcfruleForm.value.BbHosptalServerdk = parsePort(result.BbHosptalServer)
    wcfruleForm.value.ZyHosptalServerip = parseIp(result.ZyHosptalServer)
    wcfruleForm.value.ZyHosptalServerdk = parsePort(result.ZyHosptalServer)
  }else{
    window.errorMessageOpen(
			"账套信息失败",
			res.CodeMsg
		);
  }
}

const getGhyyhttp = async() => {
  let res = await window.xinpuWebsApi('GetGhyyInfo',{root:'HttpConnections'})
  console.log(res);
  if(res.Flag){
    let result = JSON.parse(res.ReContent)
    console.log(result,'配置信息');
    httpruleForms.value = result
    httpruleForm.value.httphosptalserverip = parseIp(result.httphosptalserver)
    httpruleForm.value.httphosptalserverdk = parsePort(result.httphosptalserver)
    httpruleForm.value.mzhttphosptalserverip = parseIp(result.mzhttphosptalserver)
    httpruleForm.value.mzhttphosptalserverdk = parsePort(result.mzhttphosptalserver)
    httpruleForm.value.ybhttphosptalserverip = parseIp(result.ybhttphosptalserver)
    httpruleForm.value.ybhttphosptalserverdk = parsePort(result.ybhttphosptalserver)
    httpruleForm.value.ykhttphosptalserverip = parseIp(result.ykhttphosptalserver)
    httpruleForm.value.ykhttphosptalserverdk = parsePort(result.ykhttphosptalserver)
    httpruleForm.value.dzblhttphosptalserverip = parseIp(result.dzblhttphosptalserver)
    httpruleForm.value.dzblhttphosptalserverdk = parsePort(result.dzblhttphosptalserver)
    httpruleForm.value.bbhttphosptalserverip = parseIp(result.bbhttphosptalserver)
    httpruleForm.value.bbhttphosptalserverdk = parsePort(result.bbhttphosptalserver)
    httpruleForm.value.zyhttphosptalserverip = parseIp(result.zyhttphosptalserver)
    httpruleForm.value.zyhttphosptalserverdk = parsePort(result.zyhttphosptalserver)
  }else{
    window.errorMessageOpen(
			"账套信息失败",
			res.CodeMsg
		);
  }
}

function parseIp(str) {
  const ipPortRegex = /(\b\d{1,3}\b\.\b\d{1,3}\b\.\b\d{1,3}\b\.\b\d{1,3}\b):(\d{1,5})\b/;
  const match = str.match(ipPortRegex);
  if (match) {
    return match[1]
  } else {
    return null;
  }
}

function parsePort(str) {
  const ipPortRegex = /(\b\d{1,3}\b\.\b\d{1,3}\b\.\b\d{1,3}\b\.\b\d{1,3}\b):(\d{1,5})\b/;
  const match = str.match(ipPortRegex);
  if (match) {
    return parseInt(match[2], 10)
  } else {
    return null;
  }
}

function replaceIpsInObject(obj, replacer) {
  if (typeof obj !== 'object' || obj === null) {
    return;
  }
 
  for (let key in obj) {
    if (obj.hasOwnProperty(key)) {
      if (typeof obj[key] === 'string') {
        obj[key] = obj[key].replace(/\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b/g, replacer || '');
      } else if (typeof obj[key] === 'object') {
        replaceIpsInObject(obj[key]);
      }
    }
  }
}

function replacePorts(obj, newPort) {
  for (let key in obj) {
    if (typeof obj[key] === 'object') {
      // 如果属性值是对象，则递归调用
      replacePortNumbers(obj[key]);
    } else if (typeof obj[key] === 'string') {
      // 如果属性值是字符串，则尝试替换端口号
      obj[key] = obj[key].replace(/:\d+/g, ":" + newPort);
    }
  }
}

function replaceIPsInString(str, replacement) {
  // 匹配IP地址的正则表达式
  const ipRegex = /\b(?:\d{1,3}\.){3}\d{1,3}\b/g;
  // 使用replace方法替换所有IP地址
  return str.replace(ipRegex, replacement);
}

function replacePort(url, newPort) {
  const regex = /:\d+/; // 匹配冒号后跟一个或多个数字的部分
  return url.replace(regex, ':' + newPort);
}

onMounted(()=>{
  getGhyyy()
  getGhyyhttp()
})
defineExpose({
  cancelPrompt,
  cancellation
});
</script>

<style lang="scss" scoped>
.mabiao{
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 14px;
    margin-bottom: 16px;
    .mabiao-item{
        display: flex;
        align-items: center;
        color: #333333;
        .mabiao-item-left{
          width: 84px;
          // flex: 0 0 84px;
          text-align: right;
        }
    }
}
.prompt-wcf-top{
  :deep(.el-input__wrapper){
    box-shadow:0 0 0 1px #fff !important;
  }
  :deep(.el-input__inner) {
    height: 24px !important;
    border-radius:0 !important;
    box-shadow:0 0 0 1px #fff !important;
  }
}
:deep(.el-input__inner) {
  height: 32px !important;
}
:deep(.el-select__wrapper) {
  width: 260px !important;
  height: 32px !important;
}
.prompt-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  border-radius: 4px 4px 4px 4px;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10000;
}

.prompt-box {
  background-color: #fff;
  width: 896px;
  border-radius: 2px;
  box-shadow: 0px 12px 32px 4px rgba(0, 0, 0, 0.04),
    0px 8px 20px rgba(0, 0, 0, 0.08);
  .prompt-title {
    font-size: 18px;
    color: #303133;
    width: 100%;
    height: 40px;
    padding: 0 16px;
    box-sizing: border-box;
    background: #697786;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 14px;
    color: #ffffff;
  }
  .prompt-line{
    width: 100%;
    margin: 20px 0 20px 0px;
    box-sizing: border-box;
    border-top: 1px dashed #E0E0E0;
  }
  .prompt-wcf{
    padding: 0 24px;
    box-sizing: border-box;
    .prompt-wcf-top{
      display: flex;
      align-items: center;
      justify-content: space-between;
      .prompt-wcf-top-right{
        font-size: 14px;
        color: var(--el-color-primary);
        display: flex;
        align-items: center;
        cursor: pointer;
      }
      .prompt-wcf-top-title{
        font-weight: bold;
        font-size: 16px;
        color: #333333;
        margin-right: 18px;
      }
      .prompt-wcf-top-box{
        display: flex;
        align-items: center;
        font-size: 14px;
        color: #333333;
        margin-right: 8px;
        .prompt-wcf-top-box-ip{
          width: 72px;
          height: 32px;
          border-radius: 4px 0px 0px 4px;
          border: 1px solid #E0E0E0;
          border-right: none;
          display: flex;
          align-items: center;
          justify-content: center;
        }
        .prompt-wcf-top-box-di{
          width: 178px;
          height: 32px;
          border-radius: 0px 4px 4px 0px;
          border: 1px solid #E0E0E0;
          display: flex;
          align-items: center;
          justify-content: center;
        }
      }
    }
    .prompt-wcf-center{
      width: 100%;
      height: 216px;
      background: #F7F7F7;
      border-radius: 4px 4px 4px 4px;
      padding: 16px;
      box-sizing: border-box;
      .prompt-wcf-center-item{
        width: 100%;
        font-size: 14px;
        color: #333333;
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin-bottom: 16px;
        .prompt-wcf-center-item-soft{
          flex: 0 0 50%;
          display: flex;
          align-items: center;
        }
        .prompt-wcf-center-item-label{
          flex: 0 0 84px;
          text-align: right;
        }
      }
    }
  }
  .prompt-content {
    // display: flex;
    // align-items: center;
    // justify-content: center;
    padding: 24px 24px 20px 24px;
    box-sizing: border-box;
    .demo-ruleForm{
        width: 100%;
    }
  }
  .detail-info{
    padding: 0 24px 24px 24px;
    box-sizing: border-box;
    .detail-info-top{
        display: flex;
        align-items: flex-end;
        color: #333333;
        .detail-info-top-title{
            font-size: var(--size);
        }
    }
    .detail-info-content{
        font-size: var(--size);
        color: #999999;
        width: 100%;
        margin-top: 16px;
        max-height: 188px;
        overflow-y: auto;
    }
  }
}

button {
  padding: 8px 15px;
  margin: 5px;
  cursor: pointer;
}
.prompt-footer {
  width: 100%;
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  border-top: 1px solid #E0E0E0;
  padding-right: 16px;
  box-sizing: border-box;
}
</style>
<style>
.el-popper{
    z-index: 100000 !important;
}
</style>